import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PreloadRoutersService } from '@core/router/preload-routers.service';
import { AuthGuard } from '@core/router/auth.guard';
import { HomeComponent } from './view/page/home/home.component';


const routes: Routes = [
    { path: '', redirectTo: '/page/home', pathMatch: 'full' },
	{
		path: 'home',
		component: HomeComponent,
	},
    {
        path: 'page',
        canActivateChild: [AuthGuard],
        loadChildren: () => import('./view/page/page.module').then((mod) => mod.PageModule),
    },
    {
        path: 'login',
        loadChildren: () => import('./view/login/login.module').then((lm) => lm.LoginModule),
    },
	{
        path: '',
        loadChildren: () => import('./view/exception/exception.module').then((lm) => lm.ExceptionModule),
    },
	{ path: '**', redirectTo: 'exception/404' },
];

@NgModule({
    imports: [RouterModule.forRoot(routes, { useHash: true, preloadingStrategy: PreloadRoutersService })],
    exports: [RouterModule],
    providers: [PreloadRoutersService, AuthGuard]
})
export class AppRoutingModule { }
